package com.feifan.service.impl;

import com.feifan.mapper.ContentMapper;
import com.feifan.mapper.UserMapper;
import com.feifan.pojo.ContentDTO;
import com.feifan.pojo.UserDTO;
import com.feifan.service.api.UserOperatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.Date;

/**
 * @author Donald
 * @create 2019-04-18 0:13
 */
@Service
public class UserOperator implements UserOperatorService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private ContentMapper contentMapper;

    @Override
    public UserDTO findAllRolesByUserId(Long id) throws SQLException {
        //userMapper.insertRole(2L);
        UserDTO userDTO = new UserDTO();
        userMapper.insertUser(userDTO);
        System.err.println(userDTO);
        userDTO.setEmail("1284038873@qq.com");
        userDTO.setGender("女");
        userDTO.setModifyTime(new Date());
        userMapper.updateUserBaseInfoInt(userDTO);
        System.out.println(userDTO);
        return userMapper.findAllRolesByUserId(id);
    }

    @Override
    public UserDTO findUserInfoById(Long id) throws SQLException {
        return null;
    }

    @Override
    public int insertUser(UserDTO userDTO) throws SQLException {
        return 0;
    }

    @Override
    public int insertRole(Long userId) {
        return 0;
    }

    @Override
    public int judgeUsernameIsOK(String username) {
        return 0;
    }

    @Override
    public int judgeEmailIsOK(String email) {
        return 0;
    }

    @Override
    public int insertContent(ContentDTO contentDTO) {
        contentMapper.insert(contentDTO);
        return 0;
    }
}
